<!--
 * @Descripttion: 
 * @Author: voanit
 * @Date: 2022-01-03 08:57:37
 * @LastEditors: voanit
 * @LastEditTime: 2022-01-03 09:31:37
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>

<body>

  <script>
    /*
    目的：将ajax封装成一个Promise对象，获取数据想使用 .then()====$.ajax().then()
    1-先写一个发送请求的
     */
    $(function() {
      // $.ajax({
      //   url: 'http://www.liulongbin.top:3005/api/getlunbo',
      //   data: {},
      //   success: function(res) {
      //     console.log(res,888)
      //   }
      // })

      /* Promise改造 */
      function ajaxPromise() {
        return new Promise((resolve,reject) => {
          $.ajax({
            url: 'http://www.liulongbin.top:3005/api/getlunbo',
            data: {},
            success: resolve
          })
        })
      }

      // console.log(ajaxPromise(),888)
      // ajaxPromise().then((res) => {
      //   console.log(res,888)
      // })

      const say=async () => {
        const res=await ajaxPromise()
        console.log(res,888)
      }
      say()
    })

  </script>

</body>

</html>